<?php
namespace app\user\validate\user;

use think\Validate;

/**
 * 个人中心验证
 */
class Profile extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'type'      => 'require|in:weixin,qq,sina',
        'oauth'     => 'require',
        'phone'     => 'require|mobile',
        'verify'    => 'require|number',
    ];

    protected $field = [
        'type'      => '类型',
        'oauth'     => '绑定信息',
        'phone'     => '手机号',
        'verify'    => '验证码',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
        'type.in'   => '类型错误',
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'delete_bind'   => ['type', 'verify'],
        'bind'          => ['type', 'oauth'],
        'login_bind'    => ['type', 'oauth', 'phone', 'verify'],
    ];

}
